#ifndef _ITABLEHEADER_H_
#define _ITABLEHEADER_H_

#include <BIcon>
#include <BStyle>
#include <BPainter>
#include <BSizeStretch>

#include "IAlignment.h"

namespace BWE
{
	class IHeader : public IAlignment
	{
	public:
		IHeader();

		void freshSize(const BStyle* style, const BFont* font);

		void adjustRect();

		bool			visible;
		bool			sortable;
		int				sortMode;
		Policy			policy;
		float			stretch;
		BString			label;
		BColor			color;
		BValue			asset;

		bool			dirty;
		bool			finished;
		bool			dirtyItems;
		BSize			itemsSize;
		BSize			realSize;
		BSize			hintSize;
		BSize			fixedSize;
		BString			t_label;
		BRect			rect;
		BRect			crect;
		BRect			sortUpRect;
		BRect			sortDownRect;
	};

	class IHeaderView
	{
	public:
		IHeaderView();
		~IHeaderView();

		void resetStatus();
		BRect spaceRect(int index);
		BRectf handleRect(int index);
		BRange xrange(int minx, int maxx);
		BRange yrange(int miny, int maxy);

		int sectionUnderPoint(const BPoint& point);
		int handleUnderPoint(const BPoint& point);
		void distributeWidth(int width);
		void distributeHeight(int height);

		void applyStyle(const BStyle* style);
		bool dragBegin(const BPoint& pos);
		bool drag(const BPoint& pos);
		void paint(BPainter& painter);

		Orientation			orientation;
		int					spacing;
		BSize				handleSize;
		bool				visible;
		bool				resizable;
		Align				align;
		BMargin				margin;
		BSize				baseSize;
		BSize				minSize;
		BSize				maxSize;
		BIconHolder			upIcon;
		BIconHolder			downIcon;
		BHolder<BStyle>		style;

		bool				dirty;
		int					hoverIndex;
		bool				pressed;
		BPoint				pressedPoint;
		BSize				pressedSize;
		int					handleIndex;
		bool				draging;
		BSize				hintSize;
		BSize				realSize;
		int					show_begin;
		int					show_end;
		BArray<IHeader>		headers;
	};

}

#endif